#include <iostream>
using namespace std;

const int N=505;
char s[N][N];
int dp[N][N];
int n,m;

int main() {
    
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>s[i][j];
            int t=0;
            if(s[i][j]=='l') t=4;
            else if(s[i][j]=='o') t=3;
            else if(s[i][j]=='v') t=2;
            else if(s[i][j]=='e') t=1;
            dp[i][j]=max(dp[i-1][j]+t,dp[i][j-1]+t);
        }
    }
    cout<<dp[n][m]<<endl;
    return 0;
    
}
